import app
import  requests


class CategoryApi(object):

   def __init__(self):
       self.categoryAll_url =app.URL + "/api/v1/category/all"
       self.products_url = app.URL +"/api/v1/product/by_category"
       self.product_url = app.URL + "/api/v1/product/{}"

   def getcategory_all(self):
     return  requests.get(self.categoryAll_url)

   def get_products_by_category_id(self,categoryId):
       params = {"id":categoryId}
       return  requests.get(self.products_url,params=params)

   def get_product_by_id(self,productid):

       url = self.product_url.format(productid)
       return requests.get(url=url)
